package com.niiwoo.civet.trade.service.local.notify.impl;

import com.niiwoo.civet.trade.enums.NotifyTypeEnum;
import com.niiwoo.civet.trade.service.local.newRefund.notify.dto.RefundNotifyMessageDTO;
import com.niiwoo.civet.user.dto.request.UserLetterRequestDTO;
import com.niiwoo.civet.user.enums.SMSTemplateKeyEnum;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.Arrays;

@Component
public class CardNiuProjectRepaymentCompleteNotifier extends AbstractRepaymentSuccessNotifier<RefundNotifyMessageDTO> {

    @Override
    protected UserLetterRequestDTO getUserLetterRequestDTO(UserNotifyInfo info) {
        return null;
    }

    @Override
    protected SMSRequest getSMSRequestDTO(UserNotifyInfo info) {
        RepaymentSuccessNotifyInfo cast = (RepaymentSuccessNotifyInfo) info;
        SMSRequest smsRequest = new SMSRequest();
        smsRequest.setUserId(cast.getBorrowerUserId());
        smsRequest.setSmsTemplateKeyEnum(SMSTemplateKeyEnum.CARD_NIU_REPAYMENT_LAST_PHASE);
        String projectTitle = cast.getProjectTitle();
        BigDecimal amount = cast.getAmount();
        String periodString = cast.getCurrentPeriod() + "/" + cast.getTotalPeriod();
        smsRequest.setParamList(Arrays.asList(projectTitle, periodString, amount));
        return smsRequest;
    }

    @Override
    protected NotifyTypeEnum getType() {
        return NotifyTypeEnum.CARD_JS018;
    }
}
